define("pages/bgcl/formglws", [
        '../../pages/bgcl/formglws.html.js',
        "../../common/componts",
    ],
    function(require) {
	    var comonts=require("../../common/componts");
	    var tmp= require("../../pages/bgcl/formglws.html");
	    var _show=function(_data){
            var htmlcompile = template.compile(tmp);
            var html = htmlcompile(
                {
                    title:"管理文书",
                    data:_data
                });
            $("#dlgGlws").dialog('destroy');
            $("#glwsForm").html(html);
            $(".downloadFile").each(function(){
            	$(this).on('click',function(){
				   var ids = $(this).attr("id");
				   openFile(ids,_data)
				 })
			});
            comonts.initSelect(undefined,undefined,undefined);
            $.parser.parse($("#glwsForm").parent());
            $('#dlgGlws').window('open');
            bindAction();

        }
        
        var openFile = function(ids,data){
        	var title = $("#"+ids).attr("title");
        	var labName = $("#"+ids).attr("labName");
        	$.messager.confirm("提示","确定打印"+title+"?",function(r){
        		if(r){
        			var str = 'rybh%3d';
                	var url=_reporturl(true,labName,labName,str);
                	printBB(url,title);
        		}
        	})
        }
        
        var bindAction=function(){
            var glwsId=$("#idfm").val();
        }

        var _reporturl=function(displaytool,label,name,parameters){
            return window.parent.document.getElementById("reporturl").innerHTML+'?displaytoolbar='+displaytool+'&label='+label+'&name='+name+'&parameters='+parameters;
        }
        var printBB = function(url,text){
            OpenWindow=window.open(url, text);
            var content = '<iframe scrolling="auto" frameborder="0"  src="' + url + '" style="width:100%;height:100%;"></iframe>';
            OpenWindow.document.write("<HTML>")
            OpenWindow.document.write("<TITLE>"+text+"</TITLE>")
            OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")
            OpenWindow.document.write(content)
            OpenWindow.document.write("</BODY>")
            OpenWindow.document.write("</HTML>")
            OpenWindow.document.close()
        }
        
        return{
            show:_show
        }
    });